package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.LogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.pojo.PageResult;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;
    @Override
    public PageResult<OperateLog> LogPage(Integer page, Integer pageSize) {

        //设置分页参数
        PageHelper.startPage(page,pageSize);

        //查询数据
        List<OperateLog> operateLogList = logMapper.selectAll();
        //强转为page对象
        Page<OperateLog> pageResult = (Page<OperateLog>) operateLogList;

        return new PageResult<>(pageResult.getTotal(),pageResult);
    }
}
